package com.demo2do.fms.entity.vam;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * FMS-VAM派车单信息同步表
 *
 * @author Ark
 *
 */
@Entity
@Table(name = "VAM_DISPATCH_ORDER")
public class RemoteDispatchOrder {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;
    
    /** 操作类型 */
    @Enumerated(EnumType.STRING)
    private OperationType type;
    
    /** 派车单id */
    private Long dispatchOrderId;
    
    /** 错误信息 */
    private String errorMessage;
    
    /** 创建时间 */
    private Date createTime;
    
    /** 最后更新时间 */
    private Date lastModifyTime;
    
    @Column(name = "is_disabled")
    private Boolean disabled;
    
    /**
     * The default construct
     */
    public RemoteDispatchOrder() {
    }
    
    /**
     * @param type
     * @param dispatchOrderId
     */
    public RemoteDispatchOrder(OperationType type, Long dispatchOrderId) {
        this.type = type;
        this.dispatchOrderId = dispatchOrderId;
        this.createTime = new Date();
        this.lastModifyTime = new Date();
        this.disabled = false;
    }

    /**
     * @return
     */
    public RemoteDispatchOrder success() {
        this.lastModifyTime = new Date();
        this.disabled = true;
        return this;
    }
    
    /**
     * @param errorMessage
     * @return
     */
    public RemoteDispatchOrder fail(String errorMessage) {
        this.errorMessage = errorMessage;
        this.lastModifyTime = new Date();
        this.disabled = true;
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the type
     */
    public OperationType getType() {
        return type;
    }

    /**
     * @return the dispatchOrderId
     */
    public Long getDispatchOrderId() {
        return dispatchOrderId;
    }

    /**
     * @return the errorMessage
     */
    public String getErrorMessage() {
        return errorMessage;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the lastModifyTime
     */
    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    /**
     * @return the disabled
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param type the type to set
     */
    public void setType(OperationType type) {
        this.type = type;
    }

    /**
     * @param dispatchOrderId the dispatchOrderId to set
     */
    public void setDispatchOrderId(Long dispatchOrderId) {
        this.dispatchOrderId = dispatchOrderId;
    }

    /**
     * @param errorMessage the errorMessage to set
     */
    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param lastModifyTime the lastModifyTime to set
     */
    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }
    
}
